<?php

/**
 * Controller_record
 */

class Controller_record extends MyApp {

	public function __construct()
	{
		parent::__construct();
		
		$this->model->record = YOU::loadModel('record');
	}

    /** 首页 **/
    public function actionIndex()
    {

         $this->tpl->display();
    }

	/** 教师档案设置列表 **/
    public function actionteacherRecordList()
    {	  	
    	// 设定字段
        if ($_POST){ 
        	

			$record    = array();
			
			// 判断各值不为空存入新的数组
			foreach($this->teacher_record_ini as $key => $value){
				if(!empty($_POST[$value['name']])){
					
					$record[$key] = array(
						"name"  => $value['name'],
						"title" => $value['title'],
					);
					
				}
			}
			// 保存
           $this->model->record->update("teacher_list", $record);

            // 跳转
           Helper_Client::location("修改成功", "index.php?a=record.teacherRecordList");
        }

		// 已选中设置
		$record_ini = $this->model->record->getCheck("teacher_list", $this->teacher_record_ini);

        $this->tpl->assign("record_ini", $record_ini);  
        $this->tpl->display('teacher/teacherrecord.list.tpl.php');             
    }

    /** 学生档案设置列表 **/
    public function actionstudentRecordList()
    {	
    	//  设定字段
        if ($_POST){ 
        	
			$record    = array();

			// 判断各值不为空存入新的数组
			foreach($this->student_record_ini as $key => $value){
				if(!empty($_POST[$value['name']])){
					$record[$key] = array(
						"name"  => $value['name'],
						"title" => $value['title'],
					);
				}
			}
						
           $this->model->record->update("student_list", $record);

           // 跳转
           Helper_Client::location("修改成功", "index.php?a=record.studentRecordList");
        }


		$record_ini = $this->model->record->getCheck("student_list", $this->student_record_ini);

        $this->tpl->assign("record_ini", $record_ini);  
        $this->tpl->display('student/studentrecord.list.tpl.php');             
    }
   
}
	
?>